package com.happycat.controller.home;


import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.happycat.Pagination;
import com.happycat.ResponseModel;
import com.happycat.base.R;
import com.happycat.home.dto.SysDictQueryDto;
import com.happycat.mobile.model.SysDictData;
import com.happycat.mobile.service.SysDictDataService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liaoyong
 * @since 2020-08-14
 */
@RestController
@RequestMapping("/sysDictData")
@Api(tags = "API-基础接口", description = "通用接口", value = "字典等接口")
public class SysDictDataController {
    @Autowired
	private SysDictDataService sysDictDataService;
	
//	@ApiOperation(value = "字典数据表详情")
//    @RequestMapping(method = RequestMethod.POST, value = "/detail")
//	public ResponseModel<SysDictData> detail(@RequestBody SysDictData sysDictData){
//		return sysDictDataService.selectOne(sysDictData);
//	}
	
	@RequestMapping(method = RequestMethod.POST, value = "/page")
	@ApiOperation(value = "字典数据表分页列表")
	public ResponseModel<Page<SysDictData>> Page(@RequestBody Pagination<SysDictData>page){
		return sysDictDataService.pageList(page);
	}

	@RequestMapping(method = RequestMethod.POST, value = "/allList")
	@ApiOperation(value = "字典数据表")
	public R<List<SysDictData>> allList(@Valid @RequestBody SysDictQueryDto dto){
        SysDictData dictData = BeanUtil.copyProperties(dto, SysDictData.class);
		return R.success(sysDictDataService.list(Wrappers.lambdaQuery(dictData)));
	}

	//	@RequestMapping(method = RequestMethod.POST, value = "/add")
//	@ApiOperation(value = "字典数据表新增")
//	public ResponseHeaderModel add(@RequestBody SysDictData sysDictData){
//
//	   return sysDictDataService.add(sysDictData);
//	}
//	@ApiOperation(value = "字典数据表编辑")
//	@RequestMapping(method = RequestMethod.POST, value = "/modify")
//	public ResponseHeaderModel modify(@RequestBody SysDictData sysDictData){
//
//	   return sysDictDataService.modify(sysDictData);
//	}
	
}

